namespace _4 {

var findMedianSortedArrays = function(nums1: number[], nums2: number[]): number {
    var xs = nums1.concat(nums2).sort((x, y) => x - y)
    var middle = Math.floor(xs.length/2)
    if (xs.length % 2 !== 0) return xs[middle]
    else {
        return (xs[middle] + xs[middle - 1])/2
    }
};

console.assert( findMedianSortedArrays([1, 2], [3, 4] ) === 2.5)
console.assert( findMedianSortedArrays([1, 3], [2] ) === 2.0)

}